#!/bin/bash

source_host=''
source_port=3306
source_user=''
source_database='api'
source_password=''
source_table=source_table_name

created_at="'`date -d "30 days ago" +%Y-%m-%d`'"

dest_host=''
dest_port=3306
dest_user=''
dest_database='api-archive'
dest_password=''
dest_table=dest_table_name

pt-archiver \
--source \
h=${source_host},P=${source_port},u=${source_user},p=${source_password},D=${source_database},t=${source_table},A=utf8mb4 \
--dest \
h=${dest_host},P=${dest_port},u=${dest_user},p=${dest_password},D=${dest_database},t=${dest_table},A=utf8mb4 \
--charset=utf8 \
--where 'created_at < ${$created_at}' \
--progress 10000 \
--limit=10000 \
--txn-size 10000 \
--bulk-insert \
--bulk-delete \
--statistics \
--purge
